class Sequence:
    def __init__(self,s):
        self.support=0
        self.sequence=[]
        if isinstance(s, Sequence):
            for i in range(0, s.size()): 
                self.sequence.append(s.getElement(i).clone())        
    
    def addElement(self, e):
        self.sequence.append(e)
        
    def insertElement(self,index,e):
        self.sequence.insert(index,e)
    
    def removeElement(self, index):
        if index<len(self.sequence):
            return self.sequence.pop(index)
        else:
            return None
    
    def getElement(self,index):
        if (index>=0 and index<len(self.sequence)):
            return self.sequence[index]
        else:
            print "Error in Sequence"
            return None
    
    def size(self):
        return len(self.sequence)
    
    def getElements(self):
        return self.sequence
    
    def notInSeqs(self,seqs,id):
        
        for i in range(0, len(seqs)):  
            if id==2:
                s=(seqs[i])[0]
            else:
                s=seqs[i]
            if self.isSubsequenceOf(s) and s.isSubsequenceOf(self):
                return None
        return 1
    
    def isSubsequenceOf(self,s):
        i=0
        j=0
        while (j<s.size() and i<len(self.sequence)):
            if self.getElement(i).isContainIn(s.getElement(j)):
                i+=1
                j+=1
                if i==len(self.sequence):
                    return 1
            else:
                j+=1
        return None
        
    def incrementSupport(self):
        self.support +=1
        
    def getSupport(self):
        return self.support
    
    def __repr__(self):
        s=[]
        s.append("<")
        for i in range(0, len(self.sequence)):
            s.append(self.sequence[i].__str__()) 
            if i<(len(self.sequence)-1):
                s.append(" ")
        s.append(">")
        return ''.join(s)
    
    def __str__(self):
        s=[]
        s.append("<")
        for i in range(0, len(self.sequence)):
            s.append(self.sequence[i].__str__()) 
            if i<(len(self.sequence)-1):
                s.append(" ")
        s.append(">")
        return ''.join(s)
